package work2;

import java.io.FileOutputStream;
import java.io.IOException;

public class FinallyDemo2 {
    public static void main(String[] args) {
        System.out.println("程序开始了...");
        FileOutputStream fos1=null;
        try{
            fos1=new FileOutputStream("test.dat");
            fos1.write(1);
        }catch (IOException e){
            System.out.println("出现IO异常并解决了");
        }finally {
            try {
                if(fos1!=null) {
                    fos1.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        System.out.println("程序结束了...");
    }
}
